package com.pd.backend.service.impl;

import com.pd.backend.entity.PdTruckType;
import com.pd.backend.dao.PdTruckTypeDao;
import com.pd.backend.service.PdTruckTypeService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * 车辆类型表(PdTruckType)表服务实现类
 *
 * @author GuoXinChao.126@gmail.com
 * @since 2023-02-27 17:14:36
 */
@Service("pdTruckTypeService")
public class PdTruckTypeServiceImpl implements PdTruckTypeService {
    @Resource
    private PdTruckTypeDao pdTruckTypeDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PdTruckType queryById(String id) {
        return this.pdTruckTypeDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param pdTruckType 筛选条件
     * @param pageRequest 分页对象
     * @return 查询结果
     */
    @Override
    public List<PdTruckType> queryAll() {

        return this.pdTruckTypeDao.queryAllByLimit();
    }

    /**
     * 新增数据
     *
     * @param pdTruckType 实例对象
     * @return 实例对象
     */
    @Override
    public PdTruckType insert(PdTruckType pdTruckType) {
        this.pdTruckTypeDao.insert(pdTruckType);
        return pdTruckType;
    }

    /**
     * 修改数据
     *
     * @param pdTruckType 实例对象
     * @return 实例对象
     */
    @Override
    public PdTruckType update(PdTruckType pdTruckType) {
        this.pdTruckTypeDao.update(pdTruckType);
        return this.queryById(pdTruckType.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.pdTruckTypeDao.deleteById(id) > 0;
    }
}
